package com.spring_mvc.Test;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.json.JSONUtils;
import com.spring_mvc.config.Spring;
import com.spring_mvc.dao.UserDao;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.sql.SQLException;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = Spring.class)
public class SpringTest {

    @Resource(name = "userDao")
    private UserDao userDao;

    @Resource(name = "dataSource")
    private DruidDataSource dataSource;

    @Test
    public void test1() throws SQLException {
        userDao.add();
        System.out.println(dataSource.getConnection());
    }

}
